package com.foreknow.demo2;

import java.util.Scanner;

/**
 * while循环
 */
public class LoopDemo3 {
    public static void main(String[] args) {
        //商品的名称
        String name = "";
        //价格
        double price = 0;
        //编号
        int goodsNo = 0;
        System.out.println("***********************************");
        System.out.println("购物管理系统");
        System.out.println("请选择要购买的商品的编号:");
        System.out.println("1. AAAA   2. BBBB   3. CCCC");
        System.out.println("***********************************");

        Scanner input = new Scanner(System.in);
        String answer = "y";
        while("y".equals(answer)) {
            System.out.println("请输入商品的编号:");
            goodsNo = input.nextInt();
            switch (goodsNo) {
                case 1:
                    name = "AAAA";
                    price = 245.0;
                    break;
                case 2:
                    name = "BBBB";
                    price = 200.0;
                    break;
                case 3:
                    name = "CCCC";
                    price = 199.0;
                    break;
            }
            System.out.println("商品的名称：" + name + "商品的价格：" + price);
            System.out.println("是否继续(y/n)");
            answer = input.next(); // y
        }
    }
}
